package com.zmn.oms.admin.controller.perf;

import com.zmn.common.constant.StatusConsts;
import com.zmn.common.dto.LayuiTableResponseDTO;
import com.zmn.oms.admin.controller.OmsBaseController;
import lombok.extern.slf4j.Slf4j;
import org.springframework.jdbc.BadSqlGrammarException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * @author HandsomeHan
 * @modifier wangjie
 * @date 2018/12/11 11:35
 */
@Slf4j
public class PerfBaseController extends OmsBaseController {

    @ExceptionHandler(BadSqlGrammarException.class)
    @ResponseBody
    public LayuiTableResponseDTO<Object> sqlErrorHandler(BadSqlGrammarException e) {
        log.error(e.getMessage(), e);
        LayuiTableResponseDTO<Object> errorDTO = new LayuiTableResponseDTO<>();
        errorDTO.setCode(StatusConsts.ERROR_PERMIT);
        errorDTO.setMsg("查询失败,请检查数据权限");
        errorDTO.setExtData(e);
        return errorDTO;
    }

}
